* Replication Syntax for 
* Efficiency Loss and Support for Income Redistribution. Evidence from a Laboratory Experiment
* Markus Tepe, Fabian Paetzel, Jan Lorenz, Maximiian Lutz 
* Rationality and Society, April 2021


*** Dataset

cd "~\replication_RS"
use data_ideal, clear 
append using data_fin

gen period_new =.
replace period_new = 1  if period==1 & fin==0
replace period_new = 2  if period==1 & fin==1
replace period_new = 3  if period==2 & fin==0
replace period_new = 4  if period==2 & fin==1
replace period_new = 5  if period==3 & fin==0
replace period_new = 6  if period==3 & fin==1
replace period_new = 7  if period==4 & fin==0
replace period_new = 8  if period==4 & fin==1
replace period_new = 9  if period==5 & fin==0
replace period_new = 10 if period==5 & fin==1
replace period_new = 11 if period==6 & fin==0
replace period_new = 12 if period==6 & fin==1
replace period_new = 13 if period==7 & fin==0
replace period_new = 14 if period==7 & fin==1
replace period_new = 15 if period==8 & fin==0
replace period_new = 16 if period==8 & fin==1

label  define fin_lb 1 "Final" 0 "Ideal"
label  values fin fin_lb
label var leak_cat "Leaksize"
recode leak_cat 1=. 2=1 3=2 4=3, gen(leak_cat3)

*** Analysis ***

tsset id period_new

*** Table 3
 
fracreg logit tax    i.pred_cat  i.leak_cat  i.fin leftright geschlecht alter study1 study4 study2   study5 pool1  , vce(cluster id)
est store m1
fracreg logit tax      ginc_ln   i.leak_cat  i.fin leftright geschlecht alter study1 study4 study2   study5 pool1  , vce(cluster id)
est store m2
fracreg logit tax    c.ginc_ln   i.leak_cat##i.fin leftright geschlecht alter study1 study4 study2   study5 pool1  , vce(cluster id)
est store m3
fracreg logit tax    i.pred_cat##i.fin i.leak_cat  leftright geschlecht alter study1 study4 study2   study5 pool1  , vce(cluster id)
est store m4
fracreg logit tax    c.ginc_ln##i.fin  i.leak_cat  leftright geschlecht alter study1 study4 study2   study5 pool1  , vce(cluster id)
est store m5
esttab m1 m2 m3 m4 m5 using tab3.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) pr2 aic bic compress nogaps replace label  nobaselevels  

*** Table 4

fracreg logit tax  i.pred_cat i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==0, vce(cluster id)
est store m1
fracreg logit tax  c.ginc_ln  i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==0, vce(cluster id)
est store m2
fracreg logit tax  c.ginc_ln##i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==0, vce(cluster id)
est store m3
fracreg logit tax  i.pred_cat i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==1, vce(cluster id)
est store m4
fracreg logit tax  c.ginc_ln  i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==1, vce(cluster id)
est store m5
fracreg logit tax  c.ginc_ln##i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==1, vce(cluster id)
est store m6
esttab m1 m2 m3 m4 m5 m6 using tab4.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) pr2 aic bic compress nogaps replace label  nobaselevels  

*** Figure 2

fracreg logit tax    i.pred_cat i.leak_cat##i.fin leftright geschlecht alter study1 study4 study2  study5 pool1  , vce(cluster id)
margins leak_cat#fin
marginsplot,  recast(scatter) title("Predictive Margins with 95% CIs")
graph save fig2a.gph, replace
fracreg logit tax    i.pred_cat i.leak_cat##i.fin leftright geschlecht alter study1 study4 study2  study5 pool1  , vce(cluster id)
margins leak_cat, dydx(fin)
marginsplot,  yline(0)  recast(scatter) title("Average Marginal Effect with 95% CIs")
graph save fig2b.gph, replace
graph combine fig2a.gph fig2b.gph, xsize(6) ysize(3)

*** Figure 3 (upper panel)

fracreg logit tax   i.pred_cat##i.fin i.leak_cat  leftright geschlecht alter study1 study4 study2  study5 pool1  , vce(cluster id)
margins pred_cat#fin
marginsplot, recast(scatter) title("Predictive Margins with 95% CIs") xtitle("")
graph save fig3ua.gph, replace
fracreg logit tax   i.pred_cat##i.fin i.leak_cat  leftright geschlecht alter study1 study4 study2  study5 pool1  , vce(cluster id)
margins i.pred_cat,  dydx(fin)
marginsplot,  yline(0) recast(scatter) title("Average Marginal Effect with 95% CIs") xtitle("")  
graph save fig3ub.gph, replace
graph combine fig3ua.gph fig3ub.gph, xsize(6) ysize(3) col(2)

*** Figure 3 (lower panel)

fracreg logit tax   c.ginc_ln##i.fin i.leak_cat  leftright geschlecht alter study1 study4 study2  study5 pool1  , vce(cluster id)
margins i.fin, at(c.ginc_ln = (-2.8(.5)2.2))
marginsplot, xline(0)  title("Predictive Margins with 95% CIs") xtitle("")
graph save fig3la.gph, replace
fracreg logit tax   c.ginc_ln##i.fin i.leak_cat  leftright geschlecht alter study1 study4 study2  study5 pool1  , vce(cluster id)
margins, dydx(fin) at(c.ginc_ln = (-2.8(.5)2.2)) 
marginsplot, yline(0) xline(0) title("Average Marginal Effect with 95% CIs") xtitle("") 
graph save fig3lb.gph, replace
graph combine fig3la.gph fig3lb.gph, xsize(6) ysize(3) col(2)

*** Figure 4

fracreg logit tax  c.ginc_ln##i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==0, vce(cluster id)
margins i.leak_cat, at(c.ginc_ln = (-2.8(.5)2.2))
marginsplot, xline(0)  title("Ideal: Predictive Margins with 95% CIs") xtitle("")
graph save fig4a.gph, replace
fracreg logit tax  c.ginc_ln##i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==1, vce(cluster id)
margins i.leak_cat, at(c.ginc_ln = (-2.8(.5)2.2))
marginsplot, xline(0)  title("Final: Predictive Margins with 95% CIs") xtitle("")
graph save fig4b.gph, replace
graph combine fig4b.gph fig4b.gph, xsize(6) ysize(3) ycommon

*** Appendix Table 2 

xtreg tax    i.pred_cat  i.leak_cat  i.fin leftright geschlecht alter study1 study4 study2   study5 pool1  , re vce(cluster id)
est store m1
xtreg tax      ginc_ln   i.leak_cat  i.fin leftright geschlecht alter study1 study4 study2   study5 pool1  , re vce(cluster id)
est store m2
xtreg tax    c.ginc_ln   i.leak_cat##i.fin leftright geschlecht alter study1 study4 study2   study5 pool1  , re vce(cluster id)
est store m3
xtreg tax    i.pred_cat##i.fin i.leak_cat  leftright geschlecht alter study1 study4 study2   study5 pool1  , re vce(cluster id)
est store m4
xtreg tax    c.ginc_ln##i.fin  i.leak_cat  leftright geschlecht alter study1 study4 study2   study5 pool1  , re vce(cluster id)
est store m5
esttab m1 m2 m3 m4 m5 using tabA2.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) stats(r2_w r2_b r2_o)  compress nogaps replace label  nobaselevels  

*** Appendix Table 3

xtreg tax  i.pred_cat i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==0, re vce(cluster id)
est store m1
xtreg tax  c.ginc_ln  i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==0, re vce(cluster id)
est store m2
xtreg tax  c.ginc_ln##i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==0, re vce(cluster id)
est store m3
xtreg tax  i.pred_cat i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==1, re vce(cluster id)
est store m4
xtreg tax  c.ginc_ln  i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==1, re vce(cluster id)
est store m5
xtreg tax  c.ginc_ln##i.leak_cat leftright geschlecht alter study1 study4 study2  study5 pool1  if fin==1, re vce(cluster id)
est store m6
esttab m1 m2 m3 m4 m5 m6 using tabA3.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) pr2 aic bic compress nogaps replace label  nobaselevels  

*** Appendix Table 4 

fracreg logit tax      ginc_ln   i.leak_cat3   leftright geschlecht alter study1 study4 study2   study5 pool1 if fin==0 , vce(cluster id)
est store m1
fracreg logit tax      ginc_ln   i.leak_cat3   leftright geschlecht alter study1 study4 study2   study5 pool1 if fin==1 , vce(cluster id)
est store m2
esttab m1 m2 using tabA4.csv, se(2) brackets star(* 0.10 ** 0.05 *** 0.01) scalar(ll) pr2 aic bic compress nogaps replace label  nobaselevels  

*** Appendix Figure 3

fracreg logit tax   c.ginc_ln c.leftright##i.fin i.leak_cat   geschlecht alter study1 study4 study2  study5 pool1  , vce(cluster id)
margins i.fin, at(c.leftright = (.1(.1)1))
marginsplot,   title("Predictive Margins with 95% CIs") xtitle("Ideological Right-Left Orientation")
graph save figA3a.gph, replace
fracreg logit tax   c.ginc_ln c.leftright##i.fin i.leak_cat  geschlecht alter study1 study4 study2  study5 pool1  , vce(cluster id)
margins, dydx(fin) at(c.leftright = (.1(.1)1)) 
marginsplot, yline(0)  title("Average Marginal Effect with 95% CIs") xtitle("Ideological Right-Left Orientation") 
graph save figA3b.gph, replace
graph combine figA3a.gph figA3b.gph, xsize(6) ysize(3) col(2)


